package net.wenku8.reader.view.online

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.lifecycle.viewmodel.compose.viewModel
import net.wenku8.reader.ui.lite.LitePanel


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun OnlineBookcase() {
    val onlineBookcaseViewModel = viewModel<OnlineBookcaseViewModel>()
    LaunchedEffect(Unit) {
        onlineBookcaseViewModel.initData()
    }
    LitePanel(
        hostState = onlineBookcaseViewModel.hostState,
        title = "文库书架",
        dataLoading = onlineBookcaseViewModel.dataLoading,
    ) {
        LazyColumn{
            items(items = onlineBookcaseViewModel.bookList) { book ->
                OnlineBookPreview(book)
            }
        }

    }

}